home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
281
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
2KB
Path: tko.dec.com!diamond
From: diamond@tko.dec.com (Norman Diamond)
Newsgroups: comp.std.c
Subject: Re: Are macros expanded within unused macro arguments?
Date: 2 Feb 1996 05:52:57 GMT
Organization: Digital Equipment Corporation Japan , Tokyo
Message-ID: <4es8rp$98n@usenet.pa.dec.com>
References: <DM3MC3.Atv@scr.siemens.com> <TANMOY.96Feb1102025@qcd.lanl.gov>
Reply-To: diamond@jrdv04.enet.dec-j.co.jp (Norman Diamond)
NNTP-Posting-Host: jit533.tko.dec.com
In article <TANMOY.96Feb1102025@qcd.lanl.gov>, tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) writes:
>In article <DM3MC3.Atv@scr.siemens.com> mlg@scr.siemens.com (Michael
>Greenberg) writes:
>>Is the following program legal?
>>#define foo(unused)
>>#define bar(x,y)
>>foo(bar(1))
>I read it as being legal.
Mr. Bhattacharya, I am shocked.
>>Excerpt from "6.8.3.1 Argument substitution"
>> After the arguments for the invocation of a function-like macro have
>> been identified, argument substitution takes place. A parameter in the
>> replacment list, ..., is replaced by the corresponding argument after
>> all macros contained therein have been expanded. Before being
>> substituted, each argument's preprocessing tokens are completely macro
>> replaced ... .
>You gave the reason :-) The quoted text seems to imply the following order:
> 1) Identify parameters
[...]
I think there's a preceding order as well:
0) constraints checked, including ANSI Classic section 3.8.3, page 90
lines 14 to 15: "The number of arguments in an invocation of a
function-like macro shall agree with the number of parameters in
the macro definition, and [...]"
>There is a different problem in the quoted text though: it says that
>before substitution, all macros contained in the parameter are
>supposed to be expanded. I do not think that is what is meant though:
>function like macros not followed by ( cannot be expanded according to
>the last sentence: and I guess this is what was meant anyway.
I agree; this needs a DR.
--
<< If this were the company's opinion, I would not be allowed to post it. >>
"I paid money for this car, I pay taxes for vehicle registration and a driver's
license, so I can drive in any lane I want, and no innocent victim gets to call
the cops just 'cause the lane's not goin' the same direction as me" - J Spammer